apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

defaultTasks 'clean', 'compileJava', 'test'

repositories {
    mavenCentral()
}

dependencies {
    api 'com.structurizr:structurizr-client:2.0.0'

    testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
}

compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'

sourceCompatibility = 17
targetCompatibility = 17

description = 'Plugin APIs for the Structurizr on-premises installation'
group = 'com.structurizr'

test {
    useJUnitPlatform()
}

java {
    withJavadocJar()
    withSourcesJar()
}

jar {
    manifest {
        attributes(
                'Implementation-Title':   description,
                'Implementation-Version': version
        )
    }
}

publishing {
    repositories {
        maven {
            name = "ossrh"
            url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
            credentials {
                username = findProperty('ossrhUsername')
                password = findProperty('ossrhPassword')
            }
        }
    }

    publications {
        mavenJava(MavenPublication) {
            from components.java

            pom {
                name = 'structurizr-onpremises-plugins'
                description = 'Plugin APIs for the Structurizr on-premises installation'
                url = 'https://github.com/structurizr/onpremises'

                scm {
                    connection = 'scm:git:git://github.com/structurizr/onpremises.git'
                    developerConnection = 'scm:git:git@github.com:structurizr/onpremises.git'
                    url = 'https://github.com/structurizr/onpremises'
                }

                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }

                developers {
                    developer {
                        id = "simon"
                        name = "Simon Brown"
                        email = "help@structurizr.com"
                    }
                }
            }
        }
    }
}

signing {
    sign publishing.publications.mavenJava
}